﻿//-----------------------------------------------------------------------
// <copyright file="TorrentUriResponse.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings

using System;
using System.Runtime.Serialization;

#endregion

namespace GateShift.Common.WcfDataContracts.Contracts
{
    /// <summary>
    /// DataContract sent as a response to requesting a torrent
    /// </summary>
    [DataContract]
    public struct TorrentUriResponse
    {
        // We serialize this so our public member can be strongly typed
        [DataMember(Order = 1, Name = "responseUri", IsRequired = true)]
        private string _torrentUri;

        // We serialize this so our public member can be strongly typed
        [DataMember(Order = 2, Name = "responseVersion", IsRequired = true)]
        private string _torrentVersion;

        /// <summary>
        /// Gets or sets the Uri to the torrent to download
        /// </summary>
        public Uri TorrentUri
        {
            get
            {
                return (_torrentUri != null) ? new Uri(_torrentUri) : null;
            }

            set
            {
                _torrentUri = (value != null) ? value.ToString() : null;
            }
        }

        /// <summary>
        /// Gets or sets the version for the torrent file
        /// </summary>
        public Version TorrentVersion
        {
            get
            {
                return (_torrentVersion != null) ? new Version(_torrentVersion) : null;
            }

            set
            {
                _torrentVersion = (value != null) ? value.ToString() : null;
            }
        }
    }
}